/**
 * Created by xxx on 2017年12月4日.
 */
var currentpage = 1,totlepage = 1,i,UE;//分页的当前页和总的页数
//当前第几页、总页数、总行数
var otherData = {pageLeft:0,pageRight:0};
//分页
var Page = React.createClass({
    setPage: function (e) {
        setPage($(e.target).html());
        this.props.onPageClick(1);
    },
    showPage: function () {
        showPage();
    },
    render: function () {
        {
            var items = [],
                svar = this;
            if(totlepage == 0 ){
                items.push({num:1,checked:true})
            }else if(totlepage < 6){
                for(i = 1;i <= totlepage ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage >= (totlepage-2)) {//点在左边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                for(i = totlepage-2;i <= totlepage ;i++){
                    if(i == currentpage){
                        items.push({num:i,checked:true})
                    }else{
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage <= 3){
                for(i = 1;i <= 3 ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }else {//点在两边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:currentpage-1,checked:false});
                items.push({num:currentpage,checked:true});
                items.push({num:currentpage+1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }
        }
        return (
            <div className="studentsInfo-page tableInfo-page">
                <div className="page-number">每页<span className="page-number-list" onClick={this.showPage}>{pagecount}</span>条</div>
                <div className="page-list" style={{top:pageListTop+"px"}}>
                    <ul>
                        {
                            pageList.map(function (item) {
                                return (<li onClick={svar.setPage}>{item}</li>)
                            })
                        }
                    </ul>
                </div>
                <div className="page-limit">
                    <ol className="page-limit-ol">
                        <li className="page-limit-img" name="-1" onClick={otherData.pageLeft == 0?'':svar.props.onPageClick.bind(svar,-1)} ><span className={otherData.pageLeft == 0?'page-limit-left-no':'page-limit-left-yes'}/></li>
                        {
                            items.map(function (item) {
                                return (<li onClick={isNaN(item.num)?'':svar.props.onPageClick.bind(svar,item.num)} className={item.checked == true?'page-limit-num page-limit-checked':'page-limit-num'} name={item.num}>{item.num}</li>)
                            })
                        }
                        <li className="page-limit-img" name="-2" onClick={otherData.pageRight == 0?'':svar.props.onPageClick.bind(svar,-2)}><span className={otherData.pageRight == 0?'page-limit-right-no':'page-limit-right-yes'}/></li>
                    </ol>
                </div>
            </div>
        );
    },
});
//父组件
var Main = React.createClass({
    //组件初始状态
    getInitialState: function () {
        return {
            otherData: this.props.otherData,//分页数据
            menuType: 1,//1:列表 2：审核
            navigation: "",//导航内容
            droupName:'商品名称',//下拉列表  商品名称 商户名称
            companyName:'点击选择所属商家',//所属商家选择
            businessDataList:[],//商户下拉列表
            businessDataAll:[],//所有商户列表
            businessPassDataAll:[],//查询所有审核通过的商户
            goodsTableData:[],//商户列表数据
            goodsExaTableData:[],//商户审核数据
            goodsUseDetailsTableData:[],//商品使用数据
            goodsTrData:[],//商品行数据
            goodsManPageInfo: {
                currentpage:1,//当前页
                pageLeft: 0,//0是不可点击，1反之
                pageRight: 0,//0是不可点击，1反之
                totlepage: 1,//总页数
            },//商家列表查询的数据分页信息
            goodsExaPageInfo: {
                currentpage:1,//当前页
                pageLeft: 0,//0是不可点击，1反之
                pageRight: 0,//0是不可点击，1反之
                totlepage: 1,//总页数
            },//商家审核号查询的数据分页信息
            showImg: false,//是否显示图片
            imgUrl:'',//上传图片后的地址
            updateImg: true,//在编辑的时候是否修改过图片
            goodsImgData: [
                { updateImg: true,showImg: false,imgUrl:''},
                {updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''}
                ],//goodsImgData[0] _header 商品在商城的展示图片，goodsImgData[1] _goodsDetails 详情商品头图片，goodsImgData[2]_coupon优惠券图
            addressOrType: {
                isShowAddress: true,//是否显示商家地址
                parent: false,//是否家长
                teacher: false,//是否老师
                china: false,//是否显示省市区
            },
            orderType:3,
            orderBy:'DESC',//DESC降序 ASC升序
            orderProp:2,//排序字段 1使用的时间排序,2领取时间排序,3使用状态排序
            goodsPackageData: [],//套餐数据
        }
    },
    componentDidMount: function () {
        suixun.hideLoding();//显示加载中
        this.getBusinessList();
        this.getBusinessPassList();
        this.getGoodsTableDate(1,this.state.menuType,this.state.droupName);
        UE = suixun.editor('goodsTintroduce');//初始化富文本
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($("#goodsQuery").is(":focus")){
                    this.getGoodsTableDate(1,this.state.menuType,this.state.droupName);
                    this.setNavigation('搜索结果');
                }
            }
        }.bind(this));
    },
    /**
     * 获取商品列表 商品审核的数据
     * @param page 当前页数
     * @param menuType 商品列表 商品审核
     * @param droupName 搜索下拉框列表
     */
    getGoodsTableDate: function(page,menuType,droupName){
        var start = 0;//计算查询记录数据库开始位置
        if(page>1){
            start = (page-1)*pagecount;
        }
        var params = 'start='+start+'&length='+pagecount,
            value = $("#goodsQuery").val(),
            url = '';
        var searchType = '';
        switch (droupName){
            case '商品名称':
                searchType = 1;
                break;
            case '商家名称':
                searchType = 2;
                break;
            default:
                console.log(this.state.searchType);
                break;
        }
        params += '&searchType='+searchType+'&value='+value;
        if(menuType==1){//商品列表
            url = serverUrl+'/credits/goods/archives/find_page.json?'+params+'&auditState='+2;
        }else if(menuType==2) {//商品审核
            url = serverUrl+'/credits/goods/archives/find_page.json?'+params+'&auditState='+[0,1];
        }
        suixun.showLoding();//显示加载中
        suixun.ajax(url,'',"get",function(data){
            suixun.hideLoding();
            if(data.code == 200){
                var pageInfo = {};
                if(data.info.total==0){
                    currentpage = 1;
                    otherData.pageLeft = 0;
                    otherData.pageRight = 0;
                    totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                }else {
                    pageInfo = suixun.getPageInfo(start, pagecount, data.info.total);
                    currentpage = pageInfo.currentpage;
                    otherData.pageLeft = pageInfo.pageLeft;
                    otherData.pageRight = pageInfo.pageRight;
                    totlepage = pageInfo.totlepage;//初始化的时候赋值：分页的当前页和总的页数}
                }
                if(menuType==1){//商品列表
                    this.setState({goodsTableData:data.info.list==null?[]:data.info.list,otherData:otherData,goodsManPageInfo:pageInfo});
                }else if(menuType==2) {//商品审核
                    this.setState({goodsExaTableData:data.info.list==null?[]:data.info.list,otherData:otherData,goodsExaPageInfo:pageInfo});
                }
            }else{
                suixun.alert(data.msg,function (data) {
                    if(data){
                        var pageInfo ={
                            currentpage:1,
                            pageLeft: 0,
                            pageRight: 0,
                            totlepage: 1,
                        };
                        currentpage = 1;
                        otherData.pageLeft = 0;
                        otherData.pageRight = 0;
                        totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                        if(menuType==1){//商品列表
                            this.setState({goodsTableData:[],otherData:otherData,goodsManPageInfo:pageInfo});
                        }else if(menuType==2) {//商品审核
                            this.setState({goodsExaTableData:[],otherData:otherData,goodsExaPageInfo:pageInfo});
                        }
                    }
                }.bind(this))
            }
        }.bind(this));
    },
    /**
     * 商品使用详情数据
     */
    useDetails:function (page,orderBy,orderProp) {
        // debugger;
        var start = 0;//计算查询记录数据库开始位置
        if(page>1){
            start = (page-1)*pagecount;
        }
        var archivesid= this.state.goodsTrData.id;
        var params = 'start='+start+'&length='+pagecount+'&archivesid='+archivesid+'&orderProp='+orderProp+'&type='+orderBy,
            url = serverUrl+'/credits/goods/archives/find_goods_page.json?'+params;
        suixun.showLoding();//显示加载中
        suixun.ajax(url,'',"get",function(data){
            suixun.hideLoding();
            if(data.code==200){
                var pageInfo = {};
                if(data.info.total==0){
                    currentpage = 1;
                    otherData.pageLeft = 0;
                    otherData.pageRight = 0;
                    totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                    this.setState({goodsUseDetailsTableData:[],otherData:[]});
                }else {
                    pageInfo = suixun.getPageInfo(start, pagecount, data.info.total);
                    currentpage = pageInfo.currentpage;
                    otherData.pageLeft = pageInfo.pageLeft;
                    otherData.pageRight = pageInfo.pageRight;
                    totlepage = pageInfo.totlepage;//初始化的时候赋值：分页的当前页和总的页数}
                    this.setState({goodsUseDetailsTableData:data.info.list==null?[]:data.info.list,otherData:otherData});
                }

            }else{
                suixun.alert(data.msg,function (data) {
                    if(data){
                        currentpage = 1;
                        otherData.pageLeft = 0;
                        otherData.pageRight = 0;
                        totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                        this.setState({goodsUseDetailsTableData:[],otherData:otherData});
                    }
                }.bind(this))
            }
        }.bind(this));
    },
    /**
     *设置排序按钮显示
     */
    setOrderType:function(orderBy,orderProp) {
        this.setState({
            orderBy : orderBy,//DESC降序 ASC升序
            orderProp : orderProp,
        });
        this.useDetails(1,orderBy, orderProp);
    },
    /**
     * 新增商品
     *
     */
    addGoods: function () {
        var companyId = $('#couponType').val();//商品名
        var name = $('#goodsName').val();//商品名
        var consumeCredit = $('#goodsConsumeCredit').val();//商品消耗积分
        var goodsPrice = $('#goodsPrice').val();//商品市场价值
        var goodsType = $('#goodsType').val();//商品类型
        var goodsApplyType = $('#goodsApplyType').val();//商品卡的内行
        var beginTime = $('#goodsBeginTime').val();//生效时间
        var endTime = $('#goodsEndTime').val();//失效时间
        var goodsValidRemark = $("#goodsValidRemark").val();//劵有效期备注
        var goodsUseBeginTime = $('#goodsUseBeginTime').val();//开始时间
        var goodsUseEndTime = $('#goodsUseEndTime').val();//开始时间
        var goodsUseTimeRemarks = $("#goodsUseTimeRemarks").val();//使用时间备注
        // var goodsIsTop = $("#goodsIsTop").val();//是否置顶
        var useTime = '';//使用时间
        var goodsProperty = $("#goodsProperty").val();//商品属性

        var num = $('#goodsNum').val();//库存
        if(this.state.navigation=='编辑商品'){
            num = $('#goodsNum').text();//库存
        }
        var goodsExplain = $("#goodsExplain").val();//使用规则
        var contents = UE.getContent();//获取编辑的内容

        //商家地址
        var provinceid = $('.span-provinceid3').text();//省
        var cityid = $('.span-cityid3').text();//市
        var countyid = $('.span-countyid3').text();//区
        var areaId = $('.span-countyid3').attr('data-uuid');// addressOrType.isShowAddress为true时传值
        //合作意向区域---已经地区
        var addressOrType = this.state.addressOrType;
        /**
         * 验证
         */
        //商品名
        if(name == ''){
            suixun.alert('商品名不能为空！');
            return;
        }
        //商品地址
        if(addressOrType.isShowAddress && !addressOrType.china){
            if(provinceid =='选择省份' || cityid=='选择地区' || countyid=='选择县或街道'){
                suixun.alert('请选择完整的省市区地址！');
                return;
            }
        }
        //商品消耗积分
        if(consumeCredit == ''){
            suixun.alert('商品消耗积分不能为空！');
            return;
        }else if(!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(consumeCredit)){
            suixun.alert('商品消耗积分格式错误！');
            return;
        }
        //商品消耗积分
        if(goodsPrice == ''){
            suixun.alert('商品市场价值不能为空！');
            return;
        }else if(!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(goodsPrice)){
            suixun.alert('商品市场价值格式错误！');
            return;
        }
        //生效时间
        if(beginTime == ''){
            suixun.alert('生效时间不能为空！');
            return;
        }else if(new Date(beginTime) < new Date(suixun.getNowFormatDate('yyyy-MM-dd'))){
            suixun.alert('生效时间不能小于当前时间！');
            return;
        }
        //失效时间
        if(endTime == ''){
            suixun.alert('失效时间不能为空！');
            return;
        }
        if(new Date(beginTime) > new Date(endTime)){
            suixun.alert('生效时间不能大于失效时间！');
            return;
        }

        //开始时间
        if(goodsUseBeginTime == '' && goodsUseEndTime != ''){
            suixun.alert('结束时间有值时，开始时间不能为空！');
            return;
        }else if(goodsUseBeginTime != '' && goodsUseEndTime == ''){
            suixun.alert('开始时间有值时，结束时间不能为空！');
            return;
        }else if((goodsUseBeginTime != '' && goodsUseEndTime != '') && new Date(goodsUseBeginTime) < new Date(suixun.getNowFormatDate('yyyy-MM-dd'))){
            suixun.alert('开始时间不能小于当前时间！');
            return;
        }else if(new Date(goodsUseBeginTime) > new Date(goodsUseEndTime)){
            suixun.alert('开始时间不能大于结束时间！');
            return;
        }else if((goodsUseTimeRemarks != '' && goodsUseBeginTime == '') ||(goodsUseTimeRemarks != '' && goodsUseEndTime == '') ){
            suixun.alert('开始时间和结束时间不能为空！');
            return;
        }else if(goodsUseTimeRemarks != '' && goodsUseBeginTime != '' && goodsUseEndTime != ''){
            useTime = goodsUseBeginTime+' — '+goodsUseEndTime+'&  '+goodsUseTimeRemarks;
        }else if(goodsUseBeginTime != '' && goodsUseEndTime != ''){
            useTime = goodsUseBeginTime+' — '+goodsUseEndTime;
        }

        //库存
        if(num == ''){
            suixun.alert('库存不能为空！');
            return;
        }else if(!/^[1-9]\d*$/.test(num)){
            suixun.alert('库存格式不对！');
            return;
        }
        //图片头图
        if(this.state.goodsImgData[0].updateImg&&this.state.goodsImgData[0].imgUrl==''){
            suixun.alert('请上传商品图片头图！');
            return;
        }
        //图片详情图
        if(this.state.goodsImgData[1].updateImg&&this.state.goodsImgData[1].imgUrl==''){
            suixun.alert('请上传商品图片详情图！');
            return;
        }
        //使用规则
        if(goodsExplain == ''){
            suixun.alert('使用规则不能为空！');
            return;
        }
        //商品介绍
        if(contents == ''){
            suixun.alert('商品介绍不能为空！');
            return;
        }else if(contents !=''){
            contents = contents.replace(/<table/g,'<div style="overflow: auto;  width: 100%;"><table');
            contents = contents.replace(/<\/table>/g,'<\/table><\/div>');
            contents = encodeURIComponent(contents);
        }
        goodsExplain = suixun.TransferString(goodsExplain,'<br />' );
        if(addressOrType.china){
            areaId = 'china';
        }
        /**
         * 组装数据-JSON
         */
        var paramData = {
            "name": name,
            "goodsType": goodsType,
            "consumeCredit": consumeCredit,
            "price": goodsPrice,
            "beginTime": beginTime+' 00:00:00',
            "endTime": endTime+' 23:59:59',
            "num": num,
            "instructions": goodsExplain,
            "cardType": goodsApplyType,
            "contents": contents,
            "smallImg": '',
            "useTime": useTime,
        };
        // if(goodsProperty != 0){
        paramData['cardProperty'] = goodsProperty;
        // }
        if(goodsValidRemark != ''){
            paramData['validRemark'] = goodsValidRemark;
        }
        if(this.state.goodsPackageData.length>0){
            var isValue = this.state.goodsPackageData.every(function (obj, index) {
                if(obj.name == '' || obj.number == '' || obj.price == ''){
                    return false;
                }else{
                    return true;
                }
            });
            if(isValue){
                paramData['goodsPackage'] = JSON.stringify(this.state.goodsPackageData);
            }else{
                suixun.alert('套餐类容不能为空！');
                return;
            }
        }else{
            paramData['goodsPackage'] = '';
        }
        paramData['isTop'] = false;//置顶默认为false
        /**
         * 图片格式
         */
        suixun.showLoding();//显示加载中
        //_header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
        if(this.state.navigation=='新增商品'){
            paramData['companyId'] = companyId;
            //putRange与areaId同时存在或不存在
            if(addressOrType.isShowAddress&&addressOrType.parent&&addressOrType.teacher){
                paramData['putRange'] = 0;
                paramData['areaId'] = areaId;
            }else if(addressOrType.isShowAddress&&!addressOrType.parent&&addressOrType.teacher){
                paramData['putRange'] = 1;
                paramData['areaId'] = areaId;
            }else if(addressOrType.isShowAddress&&addressOrType.parent&&!addressOrType.teacher){
                paramData['putRange'] = 2;
                paramData['areaId'] = areaId;
            }
            suixun.uploadImg('#file_header','',function (img_header) {//_header
                suixun.uploadImg('#file_goodsDetails','',function (img_goodsDetails) {//_goodsDetails
                    if(this.state.goodsImgData[2].imgUrl==''){
                        paramData.smallImg= '{"goodsHeaderImg": "'+suixun.imagesUrl+img_header+'","goodsDetailsImg": "'+suixun.imagesUrl+img_goodsDetails+'","couponImg": ""}';
                        suixun.showLoding();//显示加载中
                        this.changeGoods(serverUrl+'/credits/goods/archives/insert.json',paramData);
                    }else{
                        suixun.uploadImg('#file_coupon','',function (img_coupon) {//_coupon
                            paramData.smallImg= '{"goodsHeaderImg": "'+suixun.imagesUrl+img_header+'","goodsDetailsImg": "'+suixun.imagesUrl+img_goodsDetails+'","couponImg": "'+suixun.imagesUrl+img_coupon+'"}';
                            suixun.showLoding();//显示加载中
                            this.changeGoods(serverUrl+'/credits/goods/archives/insert.json',paramData);
                        }.bind(this));
                    }
                }.bind(this));
            }.bind(this));
        }else if(this.state.navigation=='编辑商品'){//编辑商品
            var smallImg = this.state.goodsTrData.smallImg=="缩略图地址"?{goodsHeaderImg:'',couponImg:'',couponImg:''}:$.parseJSON(this.state.goodsTrData.smallImg);
            // var smallImg = $.parseJSON(this.state.goodsTrData.smallImg);
            paramData['companyId'] = this.state.goodsTrData.companyId;
            var url = serverUrl+'/credits/goods/archives/update.json',
                img_header_b = false,
                img_goodsDetails_b = false,
                img_coupon_b = false,
                header = smallImg.goodsHeaderImg,
                goodsDetails = smallImg.goodsDetailsImg,
                coupon = smallImg.couponImg,
                interval = '';
            paramData['id'] = this.state.goodsTrData.id;//商品ID
            paramData['putRange'] = this.state.goodsTrData.putRange;
            paramData['areaId'] = this.state.goodsTrData.areaId;
            if(this.state.goodsImgData[0].updateImg){
                suixun.uploadImg('#file_header','',function (Img_header) {//_header
                    header = Img_header;
                    img_header_b = true;
                }.bind(this));
            }else{
                img_header_b = true;
            }
            if(this.state.goodsImgData[1].updateImg){
                suixun.uploadImg('#file_goodsDetails','',function (img_goodsDetails) {//_goodsDetails
                    goodsDetails = img_goodsDetails;
                    img_goodsDetails_b = true
                }.bind(this));
            }else{
                img_goodsDetails_b = true
            }
            if(this.state.goodsImgData[2].updateImg&&this.state.goodsImgData[2].imgUrl!=''){
                suixun.uploadImg('#file_coupon','',function (img_coupon) {//_coupon
                    coupon = img_coupon;
                    img_coupon_b = true
                }.bind(this));
            }else if(this.state.goodsImgData[2].updateImg&&this.state.goodsImgData[2].imgUrl==''){
                coupon = '';
                img_coupon_b = true
            }else {
                img_coupon_b = true
            }
            interval = setInterval(function () {
                if(img_header_b && img_goodsDetails_b && img_coupon_b){
                    paramData.smallImg= '{"goodsHeaderImg": "'+header+'","goodsDetailsImg": "'+goodsDetails+'","couponImg": "'+coupon+'"}';
                    this.changeGoods(url,paramData);
                    window.clearInterval(interval);
                }
            }.bind(this),500);


        }
    },
    /**
     * 获取商品详情
     */
    getGoodsDetails:function(id,menuType,navigation){
            suixun.showLoding();//显示加载中
            suixun.ajax(serverUrl+'/credits/goods/archives/find_details.json?id='+id,'',"get",function(data){
                suixun.hideLoding();//隐藏加载中
                if(data.code == 200){
                    this.setState({menuType:menuType});
                    this.setNavigation(navigation);
                        if(data.info.data && data.info.list){
                            //已经地区--组装数据
                            var addressOrType = {
                                isShowAddress: true,//是否显示商家地址
                                parent: false,//是否家长
                                teacher: false,//是否老师
                                china: false,//是否显示省市区
                            };
                            data.info.data['address'] = [];
                            var formOtherData = data.info.list[0];
                            if(formOtherData ==undefined){
                                let addressInfo = {
                                    isShowAddress: false,//是否显示商品地址
                                    parent: false,//是否家长
                                    teacher: false,//是否老师
                                    china: false,//是否显示省市区
                                    areaId: '',
                                    putRange: '',
                                    province: '',
                                    provinceUuid: '',
                                    city: '',
                                    cityUuid: '',
                                    town: '',
                                    townUuid: '',
                                };
                                data.info.data.address.push(addressInfo);
                            }else{
                                for(let j = 0;j<data.info.list.length;j++){
                                    let formOtherData = data.info.list[j];
                                    let addressInfo = {
                                        isShowAddress: false,//是否显示商品地址
                                        parent: false,//是否家长
                                        teacher: false,//是否老师
                                        china: false,//是否显示省市区
                                        areaId: '',//区的id
                                        putRange: '',
                                        province: '',
                                        provinceUuid: '',
                                        city: '',
                                        cityUuid: '',
                                        town: '',
                                        townUuid: '',
                                    };
                                    addressInfo.areaId = formOtherData.areaId;
                                    addressInfo.putRange = formOtherData.putRange;
                                    /**
                                     * 商品使用对象
                                     */
                                    if(formOtherData.putRange=='0'){
                                        addressInfo.parent = true;
                                        addressInfo.teacher = true;
                                    }else if(formOtherData.putRange=='1'){
                                        addressInfo.parent = false;
                                        addressInfo.teacher = true;
                                    }else if(formOtherData.putRange=='2'){
                                        addressInfo.parent = true;
                                        addressInfo.teacher = false;
                                    }
                                    if(formOtherData.areaId=='china'){
                                        addressInfo.isShowAddress = true;
                                        addressInfo.china = true;
                                        data.info.data.address.push(addressInfo);
                                    }else if(formOtherData.areaId!=''&&formOtherData.areaId!='china'){
                                        addressInfo.isShowAddress = true;
                                        addressInfo.china = false;
                                        addressInfo.town = formOtherData.areaName;
                                        addressInfo.townUuid = formOtherData.areaId;
                                        suixun.showLoding();//显示加载中
                                        suixun.ajax(serverUrl+'/region/getPRegion.json?uuid='+formOtherData.areaId,'',"get",function(cityidData){
                                            suixun.hideLoding();//隐藏加载中
                                            if(cityidData){
                                                addressInfo.city = cityidData.info.orgName;
                                                addressInfo.cityUuid = cityidData.info.uuid;
                                                suixun.showLoding();//显示加载中
                                                suixun.ajax(serverUrl+'/region/getPRegion.json?uuid='+cityidData.info.uuid,'',"get",function(provinceidData){
                                                    suixun.hideLoding();//隐藏加载中
                                                    if(provinceidData){
                                                        addressInfo.province = provinceidData.info.orgName;
                                                        addressInfo.provinceUuid = provinceidData.info.uuid;
                                                        data.info.data.address.push(addressInfo);
                                                        this.setTrData(data.info.data);
                                                        this.initTime();
                                                    }
                                                }.bind(this));
                                            }
                                        }.bind(this));
                                    }
                                }
                            }
                            var smallImg = data.info.data.smallImg=="缩略图地址"?{goodsHeaderImg:'',couponImg:'',couponImg:''}:$.parseJSON(data.info.data.smallImg);
                            this.changeImgData(0,{ updateImg: false,showImg: true,imgUrl:smallImg.goodsHeaderImg});
                            this.changeImgData(1,{ updateImg: false,showImg: true,imgUrl:smallImg.goodsDetailsImg});
                            if(smallImg.couponImg==''){
                                this.changeImgData(2,{ updateImg: false,showImg: false,imgUrl:smallImg.couponImg});
                            }else{
                                this.changeImgData(2,{ updateImg: false,showImg: true,imgUrl:smallImg.couponImg});
                            }
                            let goodsPackage = [];
                            if(data.info.data.goodsPackage){
                                this.setState({goodsPackageData:JSON.parse(data.info.data.goodsPackage)});
                            }
                            if(navigation=='编辑商品'){
                                $('#couponType').val(data.info.data.companyName);//商家名
                                $('#goodsName').val(data.info.data.name);//商品名
                                $('#goodsConsumeCredit').val(data.info.data.consumeCredit);//商品消耗积分
                                $('#goodsPrice').val(data.info.data.price);//商品市场价值
                                $('#goodsType').val(data.info.data.goodsType);//商品类型
                                $('#goodsApplyType').val(data.info.data.cardType);//适用对象
                                var beginTime = suixun.getNowFormatDate('yyyy-MM-dd',new Date(data.info.data.beginTime));
                                var endTime = suixun.getNowFormatDate('yyyy-MM-dd',new Date(data.info.data.endTime));
                                $('#goodsBeginTime').val(endTime.substring(0,16));//失效时间
                                $('#goodsEndTime').val(endTime.substring(0,16));//失效时间
                                $('#goodsValidRemark').val(data.info.data.validRemark);//券有效时间备注

                                if(data.info.data.useTime){
                                    let useTime = data.info.data.useTime;
                                    $('#goodsUseBeginTime').val(useTime.split('&')[0].split('—')[0].replace(/ /g,''));//使用开始时间
                                    $('#goodsUseEndTime').val(useTime.split('&')[0].split('—')[1].replace(/ /g,''));//使用结束时间
                                    $('#goodsUseTimeRemarks').val(useTime.split('&')[1]?useTime.split('&')[1].replace(/ /g,''):'');//使用时间备注
                                }

                                // $('#goodsIsTop').val(data.info.data.isTop?data.info.data.isTop:'false');//是否置顶
                                $('#goodsProperty').val(data.info.data.cardProperty?data.info.data.cardProperty:'1');//商品属性


                                $('#goodsNum').val(data.info.data.num);//库存
                                $('#goodsExplain').val(data.info.data.instructions==null?'':data.info.data.instructions.replace(/<br \/>/g,'\n'));//商品介绍
                                UE.ready(function() {//编辑器初始化完成再赋值
                                    UE.setContent(decodeURIComponent(data.info.data.contents));  //赋值给UEditor
                                });
                                this.setTrData(data.info.data);
                                this.setAddressOrTypeAll(addressOrType);
                                this.initTime();
                            }else{
                                if(navigation=='商品详情'&&this.state.menuType==1){
                                    UE.ready(function() {//编辑器初始化完成再赋值
                                        UE.setContent(decodeURIComponent(data.info.data.contents));  //赋值给UEditor
                                    });
                                    suixun.showLoding();//显示加载中
                                    suixun.ajax(serverUrl+'/credits/goods/archives/count_goods_info.json?archivesid='+data.info.data.id,'',"get",function(countGoodsData){
                                        suixun.hideLoding(200);//隐藏加载中
                                        if(countGoodsData.code == 200){
                                            data.info.data['totalNum'] = countGoodsData.info.data.totalNum;
                                            data.info.data['consumeNum'] = countGoodsData.info.data.consumeNum;
                                            data.info.data['notConsumeNum'] = countGoodsData.info.data.notConsumeNum;
                                            this.setTrData(data.info.data);
                                            this.setAddressOrTypeAll(addressOrType);
                                        }else{
                                            suixun.alert(data.msg)
                                        }
                                    }.bind(this));
                                }else{
                                    this.setTrData(data.info.data);
                                    this.setAddressOrTypeAll(addressOrType);
                                    this.initTime();
                                }
                            }
                        }
                }else{
                    suixun.alert(data.msg);
                }
            }.bind(this));
        },
    /**
     *
     * 编辑商品
     * @param url
     * @param paramData
     */
    changeGoods: function (url,paramData) {
        var svar = this;
        suixun.showLoding();//显示加载中
        $.ajax({
            url: url,
            type: 'POST',
            dataType: "json",
            data: paramData,
            success: function(data){
                suixun.hideLoding();//隐藏加载中
                if(data.code == 200){
                    suixun.alert('操作成功!',function (data) {
                        if(data){
                            svar.setNavigation('');
                            svar.onPageClick(currentpage);
                        }
                    });
                }else{
                    suixun.alert(data.msg);
                }
            }
        });
    },
    /**
     * 编辑、查看详情的时候设置
     * @param index
     * @param data
     */
    changeImgData: function (index, data) {
        this.state.goodsImgData[index] = data;
        this.setState({goodsImgData:this.state.goodsImgData});
    },
    /**
     * 改变是否显示
     */
    changAddressOrType: function () {
        if($("#goodsIsShowType").val()=='false'){
            this.setAddressOrType('isShowAddress');
        }else{
            var addressOrType = {
                isShowAddress: true,//是否显示商家地址
                parent: false,//是否家长
                teacher: false,//是否老师
                china: false,//是否显示省市区
            };
            this.setState({addressOrType:addressOrType});
        }

    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param key 设置的值
     */
    setAddressOrType: function (key) {
        this.state.addressOrType[key] = !this.state.addressOrType[key];
        this.setState({addressOrType:this.state.addressOrType});
    },
    /**
     * 设置商品AddressOrType
     * @param value 设置的值
     */
    setAddressOrTypeAll: function (value) {
        this.setState({addressOrType:value});
    },
    /**
     * 设置商家地址是否显示 是否选择全国 商品使用对象家长或者老师
     * @param value 设置的值
     */
    setTrData: function (value) {
        this.setState({goodsTrData:value});
    },
    /**
     * 设置导航名称
     * @return {XML}
     */
    setNavigation: function (name) {
        this.setState({navigation:name});
        if(name=='' || name=='搜索结果'){
            this.getGoodsTableDate(1,this.state.menuType,this.state.droupName);
        }
        var addressOrType = {
            isShowAddress: true,//是否显示商家地址
            parent: false,//是否家长
            teacher: false,//是否老师
            china: false,//是否显示省市区
        };
        this.setAddressOrTypeAll(addressOrType);

        if(name=='商品详情>使用详情'){
            this.setState({orderBy:'DESC',orderProp:2});
            this.useDetails(1,'DESC', 2);
        }
        if(name=='商品详情'){
            this.setState({orderBy:'DESC',orderProp:2});
        }
        if(name=='新增商品'|| name=='编辑商品'){
            this.initTime();
            UE.ready(function() {//编辑器初始化完成再赋值
                UE.setContent('');  //赋值给UEditor
            });
        }
        if(name=='新增商品' || name=='编辑商品' || name=='商品详情'){
           if(name=='商品详情'){
                UE.setDisabled('fullscreen');
            }else{
                UE.setEnabled();
            }
        }
    },
    /**
     * 初始化时间插件
     */
    initTime: function () {
        setTimeout(function () {
            $('#goodsBeginTime').datetimepicker({
                format: "Y-m-d", //格式化日期
                timepicker: false, //显示时间选项
                todayButton: false, //关闭选择今天按钮
                step:1,//时间间隔
                minDate: suixun.getNowFormatDate('yyyy-MM-dd'), // and tommorow is maximum date calendar
            });
            $('#goodsEndTime').datetimepicker({
                format: "Y-m-d", //格式化日期
                timepicker: false, //显示时间选项
                todayButton: false, //关闭选择今天按钮
                step:1,//时间间隔
                minDate: suixun.getNowFormatDate('yyyy-MM-dd'), // and tommorow is maximum date calendar
            });
            $('#goodsUseBeginTime').datetimepicker({
                datepicker:false,//关闭日期选项
                format:'H:i',//格式化日期
                // timepicker: false, //显示时间选项
                todayButton: false, //关闭选择今天按钮
                step:1,//时间间隔
                // minDate: suixun.getNowFormatDate('HH:MM'), // and tommorow is maximum date calendar
            });
            $('#goodsUseEndTime').datetimepicker({
                datepicker:false,//关闭日期选项
                format:'H:i',//格式化日期
                // timepicker: false, //显示时间选项
                todayButton: false, //关闭选择今天按钮
                step:1,//时间间隔
                // minDate: suixun.getNowFormatDate('HH:MM'), // and tommorow is maximum date calendar
            });
        },100);
    },
    /**
     * 切换菜单点击按钮
     * @return {XML}
     */
    changeMenu: function (type) {
        $("#goodsQuery").val('');//搜索框制空
        this.getGoodsTableDate(1,type,'商品名称');
        this.setState({menuType:type,droupName:'商品名称'});
        this.setGoodsInfo();
        if(this.state.navigation!=''){
            this.setNavigation('');
        }
    },
    /**
     * 设置下拉选择框内容
     * @return {XML}
     */
    setDroup: function (name) {
        if(name != this.state.droupName){
            $("#goodsQuery").val('');
        }
        this.setState({droupName:name});
    },
    /**
     * 点击搜索输入框
     * @return {XML}
     */
    onClickQueryInput: function (e) {
        if(this.state.droupName == "商家名称"){
            this.businessArray($(e.target).val(),$(e.target).attr("data-list"));
        }
    },
    /**
     * 改变搜索输入框的值
     * @return {XML}
     */
    onChangQueryInput: function (e) {
        if(this.state.droupName == "商家名称"){
            var val = $(e.target).val();
            if(val != ""){
                this.businessArray(val,$(e.target).attr("data-list"));
            }else{
                $("."+$(e.target).attr("data-list")+"").hide();
            }
        }
    },
    /**
     *点击商家名称搜索输入框
     */
    onClickBar: function (name) {
        $("#goodsQuery").val(name);
        this.setNavigation('搜索结果');
        this.getGoodsTableDate(1,this.state.menuType,this.state.droupName);
    },
    /**
     * 获取所有商户
     */
    getBusinessList: function () {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/company/find_all_name.json','',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                for(var i=0;i<data.info.list.length;i++){
                    this.state.businessDataList[i] = {key:i,name:data.info.list[i]};
                }
                this.setState({businessDataList:this.state.businessDataList,businessDataAll:this.state.businessDataList});
            }else{
                this.setState({businessDataList:this.state.businessDataList,businessDataAll:this.state.businessDataList});
            }
        }.bind(this));
    },
    /**
     * 获取所有通过的商户名称
     */
    getBusinessPassList: function () {
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/credits/company/find_all_pass_name.json','',"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                if(data.info){
                    this.setState({businessPassDataAll:data.info.list});
                }else{
                    this.setState({businessPassDataAll:[]});
                }
            }else{
                suixun.alert(data.msg);
                this.setState({businessPassDataAll:[]});
            }
        }.bind(this));
    },
    /**
     * 排序
     * @param val
     * @param cls
     */
    businessArray: function (val,cls) {
        var businessDataList = [];
        for(var i = 0;i < this.state.businessDataAll.length;i++){
            if((this.state.businessDataAll[i].name).indexOf(val) >= 0){
                businessDataList.push({name:this.state.businessDataAll[i].name});
            }
        }
        if(businessDataList.length == 0){
            $("."+cls+"").hide();
        }else{
            $("."+cls+"").show();
            this.setState({businessDataList:businessDataList});
        }
    },
    /**
     * 商品列表——编辑商品
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    onClickEdit: function (trData) {
        this.getGoodsDetails(trData.id,this.state.menuType,'编辑商品');
    },
    /**
    * 商品详情
    */
    goodsDetails: function (trData) {
        if(this.state.menuType==1){
            this.getGoodsDetails(trData.id,this.state.menuType,'商品详情');
        }else{
            this.getGoodsDetails(trData.id,this.state.menuType,'商品详情');
        }
    },
    /**
     * 点击删除
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    onClickDelete:function (trData) {
    },/**
     * 删除商品
     * @param info goodsTrData
     */
    goodsDelete: function (info) {
        var svar = this;
        suixun.confirm_noTit('确定删除此商品?',function (data) {
            if(data == true){
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+'/credits/goods/archives/delete.json?id='+info.id,'',"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200){
                        suixun.alert("删除成功!",function (data) {
                            if(data){
                                svar.onPageClick(currentpage);//更新数据
                            }
                        })
                    }else{
                        suixun.alert("删除失败!")
                    }
                });
            }
        });
    },
    /**
     * 商家审核——审核通过、审核不通过
     * @param type  true审核通过 反之
     * @param trData  表单一行的数据
     * @returns {XML}
     */
    goodsExaExamine: function (type,trData) {
        var title = '是否确定通过该商品审核？';
        if(!type){
            title = '是否确定不通过该商品审核？';
        }
        suixun.confirm_noTit(title, function (data) {
            if(data){
                var data = new FormData();
                data.append("isPass",type);
                if(this.state.navigation!=''){
                    var busiOpinion = $("#busiOpinion").val();
                    if(busiOpinion==''){
                        // setTimeout(function () {
                        //     suixun.alert('审核意见不能为空！');
                        // },1);
                        // return;
                        data.append("opinion",type?'通过':'不通过');
                    }else{
                        data.append("opinion",busiOpinion);
                    }

                }else{
                    data.append("opinion",type?'通过':'不通过');
                }
                data.append("id",trData.id);
                suixun.showLoding();//显示加载中
                suixun.ajax(serverUrl+'/credits/goods/archives/audit_archives.json',data,"post",function(data){
                    suixun.hideLoding();//隐藏加载中
                    if(data.code == 200){
                        suixun.alert('操作成功!',function (data) {
                            if(data){
                                this.onPageClick(currentpage);
                                this.setNavigation('');//设置导航为空 “商家审核>商家详情”这种状态是使用
                            }
                        }.bind(this));
                    }else{
                        suixun.alert(data.msg);
                    }
                }.bind(this));
            }
        }.bind(this));
    },
    /**
     * 关闭图片
     * @returns {XML}type 多个上传是区分作用 _header 后缀 积分商城商品图片 _goodsDetails 商品详情头图片 _coupon优惠券图片
     */
    closeImg: function(type) {
        document.querySelector('#file' + type + '').value = '';
        this.setImgData(type);
    },
    /**
     * 表单制空
     */
    setGoodsInfo:function(){
        $('#goodsName').val('');//
        $('#goodsConsumeCredit').val('');//
        $('#goodsPrice').val('');//
        $('#goodsType').val('');//
        $('#goodsBeginTime').val('');
        $('#goodsEndTime').val('');
        $('#goodsValidRemark').val('');
        $('#goodsUseBeginTime').val('');
        $('#goodsUseTimeRemarks').val('');
        $('#goodsUseEndTime').val('');
        $('#goodsNum').val('');
        $('#goodsIsTop').val('false');
        $('#goodsProperty').val('1');
        // $('#goodsTintroduce').val('');
        $('#goodsExplain').val('');
        $('#busiTintroduce').val('');
        $('.span-provinceid1,.span-provinceid2').text('选择省份');//省
        $('.span-cityid1,.span-cityid2').text('选择地区');//市
        $('.span-countyid1,.span-countyid2').text('选择县或街道');//区
        $('#adressDetails').val('');//
        //已选地区
        this.setState({
            addressData: [],
            goodsPackageData: [],
            addressOrType:{
                isShowAddress: true,//是否显示商家地址
                parent: false,//是否家长
                teacher: false,//是否老师
                china: false,//是否显示省市区
            }
        });
        this.setImgData();
    },
    /**
     * 制空图片
     */
    setImgData:function(type){
        if(type=='_header'){
            this.state.goodsImgData[0].showImg = false;
            this.state.goodsImgData[0].imgUrl = '';
            this.state.goodsImgData[0].updateImg = true;
        }else if(type=='_goodsDetails'){
            this.state.goodsImgData[1].showImg = false;
            this.state.goodsImgData[1].imgUrl = '';
            this.state.goodsImgData[1].updateImg = true;
        }else if(type=='_coupon'){
            this.state.goodsImgData[2].showImg = false;
            this.state.goodsImgData[2].imgUrl = '';
            this.state.goodsImgData[2].updateImg = true;
        }else{
            this.state.goodsImgData = [
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                { updateImg: true,showImg: false,imgUrl:''},
                {updateImg: true,showImg: false,imgUrl:''}
            ];
        }
        this.setState({goodsImgData:this.state.goodsImgData});
    },
    /**
     * 加载图片
     * @returns {XML}type 多个上传是区分作用 _header后缀 积分商城商品图片 _goodsDetails 商品详情头图片 _coupon优惠券图片
     */
    imgLoad: function (type) {
        new Viewer(document.querySelector('#showImg'+type+''));//调用图片
    },
    /**
     * 选择图片
     * @param type 多个上传是区分作用 _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     */
    onChangFile: function (type) {
        var fileUrl = $("#file"+type+"").val().split('\\');//注split可以用字符或字符串分割
        var fileName = fileUrl[fileUrl.length-1];//这就是要取得的图片名称
        var fileLat = fileName.substring( fileName.lastIndexOf('.')+1 );//后缀名称
        if(fileLat == "png" || fileLat == "jpg" || fileLat == "gif" || fileLat == "svg"){
            suixun.getImgInfo('file'+type+'',function (imgInfo) {
                if(imgInfo.size>5*1024*1024){
                    suixun.alert("图片不能大于5M！");
                }else{
                    if(type=='_header'){
                        if(imgInfo.width!=200||imgInfo.height!=200){
                            suixun.alert("商品图片头图格式不对！");
                            return;
                        }
                        this.state.goodsImgData[0].showImg = true;
                        this.state.goodsImgData[0].imgUrl = imgInfo.src;
                    }else if(type=='_goodsDetails'){
                        if(imgInfo.width!=750||imgInfo.height!=300){
                            suixun.alert("商品图片详情图格式不对！");
                            return;
                        }
                        this.state.goodsImgData[1].showImg = true;
                        this.state.goodsImgData[1].imgUrl = imgInfo.src;
                    }else if(type=='_coupon'){
                        if(imgInfo.width!=500||imgInfo.height!=130){
                            suixun.alert("商品优惠券图格式不对！");
                            return;
                        }
                        this.state.goodsImgData[2].showImg = true;
                        this.state.goodsImgData[2].imgUrl = imgInfo.src;
                    }
                    this.setState({goodsImgData:this.state.goodsImgData});
                }
            }.bind(this));
        }else{
            suixun.alert("请选择图片文件上传!",function (data) {
                if(data){
                    $("#file"+type+"").val("");
                    if(type=='_header'){
                        this.state.goodsImgData[0].showImg = false;
                        this.state.goodsImgData[0].imgUrl = '';
                    }else if(type=='_goodsDetails'){
                        this.state.goodsImgData[1].showImg = false;
                        this.state.goodsImgData[1].imgUrl = '';
                    }else if(type=='_coupon'){
                        this.state.goodsImgData[2].showImg = false;
                        this.state.goodsImgData[2].imgUrl = '';
                    }
                    this.setState({goodsImgData:this.state.goodsImgData});
                }
            }.bind(this));
        }
    },
    /**
     * 分页
     * @param num
     */
    onPageClick: function (num) {
        if(num > 0){
            currentpage = num;
        }else if(num == -1 && currentpage > 1){
            currentpage --;
        }else if(num == -2  && currentpage < totlepage){
            currentpage ++;
        }
        if(this.state.navigation ==  '商品详情>使用详情'){
            this.useDetails(1,this.state.orderBy, this.state.orderProp);
        }else{
            this.getGoodsTableDate(currentpage,this.state.menuType,this.state.droupName);
        }
    },
    /**
     * 券有效期 改变生效时间
     * @param e
     */
    changeBeginTime: function (element,e) {
        if(new Date($('#'+element).val())<new Date(e.target.value)){
            $('#'+element).val('')
        };
        $('#'+element).datetimepicker({
            format: "Y-m-d", //格式化日期
            timepicker: false, //显示时间选项
            todayButton: false, //关闭选择今天按钮
            step:1,//时间间隔
            minDate: e.target.value, // and tommorow is maximum date calendar
        });
    },
    /**
     * 获取默认图片
     * @param e
     */
    defaultImg(e){
        e.target.src = '../img/image/splitImg.jpg';
    },
    /**
     * 加载图片
     * @param type  _header 商品图片头图 _goodsDetails 商品图片详情图 _coupon 商品优惠券图片
     * @returns {XML}
     */
    imgLoad: function (type) {
        new Viewer(document.querySelector('#showImg'+type+''));//调用图片
    },
    /**
     * 设置套餐价格参数
     * @param index
     * @param type name number price
     * @param element
     */
    setGoodsPackage: function (index, type, element) {
        let goodsPackageData = this.state.goodsPackageData;
        let value = element.target.value;
        if(value){
            if((type == 'price' && !/^\d+\.?\d{0,2}$/.test(value)) || (type == 'number' && !/^[0-9]*[1-9][0-9]*$/.test(value))){
                value = goodsPackageData[index][type]
            }
        }
        goodsPackageData[index][type] = value;
        this.setState({goodsPackageData:goodsPackageData})
    },
    /**
     * 添加一个设备套餐
     */
    addGoodsPackage: function () {
        let goodsPackageData = this.state.goodsPackageData;
        goodsPackageData.push({
            name:'',
            number: '',
            price: '',
        });
        this.setState({goodsPackageData:goodsPackageData})
    },
    /**
     * 删除一个设备套餐
     */
    deleteGoodsPackage: function (index) {
        let goodsPackageData = this.state.goodsPackageData;
        if(goodsPackageData.length == 1){
            goodsPackageData = [];
        }else{
            goodsPackageData.splice(index, 1);
        }
        this.setState({goodsPackageData:goodsPackageData})
        console.log(goodsPackageData);
    },
    /**
     * 商品是否置顶
     * @param trData
     * @return {XML}
     */
    setGoodsIsTop: function (trData) {
        let svar = this;
        suixun.confirm_noTit(trData.isTop?'是否取消置顶？':'是否置顶？',function (isOk) {
            if(isOk){
                suixun.showLoding();//显示加载中
                    let paramData = {
                        "id": trData.id,
                        "isTop": trData.isTop?!trData.isTop:true,
                    };
                    $.ajax({
                        url: serverUrl+'/credits/goods/archives/top.json',
                        type: 'POST',
                        dataType: "json",
                        data: paramData,
                        success: function(data){
                            suixun.hideLoding();//隐藏加载中
                            if(data.code == 200){
                                suixun.alert('操作成功!',function (data) {
                                    if(data){
                                        svar.setNavigation('');
                                        svar.onPageClick(currentpage);
                                    }
                                });
                            }else{
                                suixun.alert(data.msg);
                            }
                        }
                    });
            }
        })
    },
    render: function () {
        {
            /**
             * 商品管理、商品审核数据
             */
            var goodsTrData = this.state.goodsTrData,Tables =  '';
            var goodsTypeValue = '免费券';//免费券，特价券，抵用券，折扣券
            switch (this.state.goodsTrData.goodsType) {
                case 1:
                    goodsTypeValue = '免费券';
                    break;
                case 2:
                    goodsTypeValue = '特价券';
                    break;
                case 3:
                    goodsTypeValue = '抵用券';
                    break;
                case 4:
                    goodsTypeValue = '折扣券';
                    break;
                default:
                    goodsTypeValue = '未获取到数据';
                    break;
            }
            if(this.state.navigation  == '商品详情>使用详情'){
                Tables = this.state.goodsUseDetailsTableData.map(function (data,index) {
                    return (
                        <tr>
                            <td style={{width: '5%'}}>{index + 1}</td>
                            <td style={{width: '20%'}}>{data.name}</td>
                            <td style={{width: '20%'}}>{data.uuid}</td>
                            <td style={{width: '10%'}}>{data.consumeState}</td>
                            <td style={{width: '15%'}}>{data.peopletel}</td>
                            <td style={{width: '15%'}}>{data.acquireTime}</td>
                            <td style={{width: '15%'}}>{data.consumeTime==null?'---':data.consumeTime}</td>
                        </tr>
                    )
                }.bind(this));
            } else if(this.state.navigation==''||this.state.navigation=='搜索结果'){
                if(this.state.menuType==1){//商品管理
                Tables = this.state.goodsTableData.map(function (data,index) {
                    var putRanges= data.putRanges==null?'3':data.putRanges,putRangesValue='未投放';//0家长教师端 1 教师端 2 家长端 3 未投放
                    if(putRanges.indexOf('0')>-1||(putRanges.indexOf('1')>-1&&putRanges.indexOf('2')>-1))
                    {
                        putRangesValue='家长教师端';
                    }else if(putRanges.indexOf('1')>-1){
                        putRangesValue='教师端' ;
                    }else if(putRanges.indexOf('2')>-1){
                        putRangesValue='家长端';
                    }
                    return (
                        <tr>
                            <td style={{width: '5%'}}>{index + 1}</td>
                            <td style={{width: '20%'}}>{data.name}</td>
                            <td style={{width: '15%'}}>{data.uuid}</td>
                            <td style={{width:'10%'}}>{putRangesValue}</td>
                            <td style={{width: '5%'}}>{data.isShow}</td>
                            <td style={{width: '20%'}}>{data.createTime}</td>
                            <td style={{width: '25%'}}>
                                <div className='trButton trLeft trButton'
                                     onClick={this.onClickEdit.bind(this, data)}>编辑
                                </div>
                                <div className='trButton trLeft table-select'
                                     onClick={this.goodsDetails.bind(this, data)}>详情
                                </div>
                                {
                                    data.isTop?
                                        <div className="trButton trLeft table-select trLong" onClick={this.setGoodsIsTop.bind(this, data)} >取消置顶</div>
                                        :
                                        <div className="trButton trLeft table-select" onClick={this.setGoodsIsTop.bind(this, data)} >置顶</div>
                                }
                                <div className='trButton trLeft table-select trLong '
                                     onClick={this.goodsDelete.bind(this, data)}>删除
                                </div>
                            </td>
                        </tr>
                    )
                }.bind(this));
            } else if(this.state.menuType==2){//商品审核
                Tables = this.state.goodsExaTableData.map(function (data,index) {
                    return (
                        <tr>
                            <td style={{width: '5%'}}>{index + 1}</td>
                            <td style={{width: '20%'}}>{data.name}</td>
                            <td style={{width: '15%'}}>{data.uuid}</td>
                            <td style={{width: '15%'}}>{data.isShow}</td>
                            <td style={{width: '20%'}}>{data.createTime}</td>
                            <td style={{width: '35%'}}>
                                <div className='trButton trLeft trButton'
                                     onClick={this.goodsDetails.bind(this, data)}>详情
                                </div>
                                <div className='trButton trLeft table-select'
                                     onClick={this.goodsExaExamine.bind(this, true, data)}>通过
                                </div>
                                <div className='trButton trLeft table-select trLong '
                                     onClick={this.goodsExaExamine.bind(this, false, data)}>不通过
                                </div>
                            </td>
                        </tr>
                    )
                }.bind(this));
            }}
        }
        var queryDataLists = this.state.businessDataList.map(function (data) {
            return (
                <span className="businessNameList-value  schoolList-value" onClick={this.onClickBar.bind(this,data.name)}>{data.name}</span>
            )
        }.bind(this));
        var isShowAddressAll = false;
        var addressAll = '';
        var useObjects = '';
        if(goodsTrData.address){
            for(let p = 0;p<goodsTrData.address.length;p++){
                let add = goodsTrData.address[p].province+' '+goodsTrData.address[p].city+' '+goodsTrData.address[p].town;
                if(goodsTrData.address[p].china){
                    add = '全国';
                }
                if(addressAll.indexOf(add)==-1){
                    addressAll += ','+add;
                }
                if(goodsTrData.address[p].isShowAddress){
                    isShowAddressAll = true;
                }
                if(goodsTrData.address[p].parent && useObjects.indexOf('家长') == -1){
                    useObjects += '家长 '
                }
                if(goodsTrData.address[p].teacher && useObjects.indexOf('老师')==-1){
                    useObjects += '老师 '
                }
            }
            addressAll = addressAll.substring(1,addressAll.length);
        }
        return(
        <div className="tableManage-body">
            <header>

                <div className="header-left"
                     style={this.state.navigation == '' ? {display: 'none'} : {display: 'block'}}>
                    <div style={this.state.navigation != '' ? {display: 'none'} : {display: 'block'}}
                         className='navigation'>{this.state.menuType == 1 ? '商品管理' : '商品审核'}</div>
                    <div style={this.state.navigation == '' ? {display: 'none'} : {display: 'block'}}
                         className='navigation selsect'>
                        <a href="javascript:void(0);"
                           onClick={this.changeMenu.bind(this, this.state.menuType)}>{this.state.menuType == 1 ? '商品管理' : '商品审核'}</a><span>>
                        {
                            this.state.navigation?this.state.navigation.indexOf('>')>-1?
                                <span>
                                        <a href="javascript:void(0);" onClick={this.setNavigation.bind(this,'商品详情')}>商品详情</a>
                                        <span>>{this.state.navigation.split('>')[1]}</span>
                                    </span>
                                :
                                this.state.navigation:''
                        }
                        </span>
                    </div>
                </div>

                <div className="header-left"
                     style={this.state.navigation != '' ? {display: 'none'} : {display: 'block'}}>
                    <div className="header-left-studentInfo">
                <span
                    className={this.state.menuType == 1 ? "header-left-button menu-width showOrder " : "header-left-button menu-width "}
                    onClick={this.changeMenu.bind(this, 1)}>商品列表</span>
                        <span
                            className={this.state.menuType == 2 ? "header-left-button showOrder " : "header-left-button "}
                            onClick={this.changeMenu.bind(this, 2)}>商品审核</span>
                    </div>
                </div>

                <div className="header-right"
                     style={this.state.navigation != '' ? this.state.navigation=='搜索结果'? {display: 'block'} : {display: 'none'} : {display: 'block'}}>
                    <div className="header-right-select droup-select droup-type">
                        <div className="school-or-table school-or-parent">{this.state.droupName}</div>
                        <span className="lower-right-corner"/>
                        <div className="drop-down left-drop-down">
                            <span className="select-value school-name"
                                  onClick={this.setDroup.bind(this, '商品名称')}>商品名称</span>
                            <span className="select-value school-name"
                                  onClick={this.setDroup.bind(this, '商家名称')}>商家名称</span>
                        </div>
                    </div>
                    <div className="header-query retrieval">
                        <div className="header-query-input">
                            <input className="query-value enterEvent" type="text" id="goodsQuery"
                                   data-list="queryDateList"
                                   onChange={this.onChangQueryInput} onClick={this.onClickQueryInput}
                                   maxLength={this.state.droupName == '商家名称' ? "50" : "11"}
                                   placeholder={"请输入" + this.state.droupName + '关键字搜索'}/>
                        </div>
                        <div className="header-query-img" onClick={this.setNavigation.bind(this, '搜索结果')}/>
                        <div className="schoolList businessList queryDateList" data-inputId="goodsQuery">
                            {queryDataLists}
                        </div>
                    </div>
                    <div className="header-right-botton" onClick={this.setNavigation.bind(this, '新增商品')}>新增商品</div>
                </div>

            </header>
            {
                /**
                 * 商品详情>使用详情
                 */
            }
            {
                this.state.navigation=='商品详情>使用详情'?<div className="body-content">
                    <div className="body-content-text" style={{paddingLeft:'0'}}>
                        <div className="content-border element-content noBorder textInput" >领取量：{goodsTrData.totalNum}&nbsp;&nbsp;&nbsp;&nbsp;已使用：{goodsTrData.consumeNum}&nbsp;&nbsp;&nbsp;&nbsp;未使用：{goodsTrData.notConsumeNum}</div>
                    </div>
                </div>:''
            }
            {
                /**
                 * 商家列表、商家审核、商家-商品列表
                 */
            }
            {
                this.state.navigation == '' || this.state.navigation=='搜索结果' || this.state.navigation=='商品详情>使用详情'?
                    <div className="tableInfo" >
                        <div className="tableInfo-data">
                            <div className="tableInfo-data-table">
                                <table className="head-body">
                                    {
                                        this.state.navigation!='商品详情>使用详情'?
                                            this.state.menuType==1?
                                            <thead>
                                                <th style={{width: '5%'}}>序号</th>
                                                <th style={{width: '20%'}}>商品名</th>
                                                <th style={{width: '20%'}}>商品号</th>
                                                <th style={{width:'10%'}}>投放对象</th>
                                                <th style={{width: '5%'}}>是否展示</th>
                                                <th style={{width: '20%'}}>创建时间</th>
                                                <th style={{width: '20%'}}>操作</th>
                                            </thead>
                                                :
                                            <thead>
                                                <th style={{width: '5%'}}>序号</th>
                                                <th style={{width: '20%'}}>商品名</th>
                                                <th style={{width: '20%'}}>商品号</th>
                                                <th style={{width: '15%'}}>是否展示</th>
                                                <th style={{width: '20%'}}>创建时间</th>
                                                <th style={{width: '20%'}}>操作</th>
                                            </thead>
                                        :
                                            <thead>
                                                <th style={{width: '5%'}}>序号</th>
                                                <th style={{width: '20%'}}>商品名</th>
                                                <th style={{width: '20%'}}>券号</th>
                                                <th style={{width: '10%'}}>使用状态
                                                    <span className={this.state.orderBy == 'ASC'&&this.state.orderProp ==3?"triangle-up select":"triangle-up "} onClick={this.setOrderType.bind(this,'ASC',3)}/>
                                                    <span className={this.state.orderBy == 'DESC'&&this.state.orderProp ==3?"triangle-bottom select":"triangle-bottom "} onClick={this.setOrderType.bind(this,'DESC',3)}/>
                                                </th>
                                                <th style={{width: '15%'}}>账号</th>
                                                <th style={{width: '15%'}}>领取时间
                                                    <span className={this.state.orderBy == 'ASC'&&this.state.orderProp ==2?"triangle-up select":"triangle-up "} onClick={this.setOrderType.bind(this,'ASC',2)}/>
                                                    <span className={this.state.orderBy == 'DESC'&&this.state.orderProp ==2?"triangle-bottom select":"triangle-bottom "} onClick={this.setOrderType.bind(this,'DESC',2)}/>
                                                </th>
                                                <th style={{width: '15%'}}>使用时间
                                                    <span className={this.state.orderBy == 'ASC'&&this.state.orderProp ==1?"triangle-up select":"triangle-up "} onClick={this.setOrderType.bind(this,'ASC',1)}/>
                                                    <span className={this.state.orderBy == 'DESC'&&this.state.orderProp ==1?"triangle-bottom select":"triangle-bottom "} onClick={this.setOrderType.bind(this,'DESC',1)}/>
                                                </th>
                                            </thead>
                                    }
                                    <tbody>
                                    {Tables == "" ? '' : Tables}
                                    </tbody>
                                </table>
                                {Tables == "" ? <div className="tableNoData">{tableNoDataCount}</div> : ''}
                            </div>
                        </div>
                        <Page otherData={this.state.otherData} onPageClick={this.onPageClick} />
                    </div> : ''
            }

            {
                /**
                 * 新增商品，编辑商品，商品详情
                 */
            }

                    <div className="body-updateAttendance" style={{display:this.state.navigation=='新增商品'||this.state.navigation=='编辑商品'||this.state.navigation=='商品详情'?'block':'none'}}>

                        <div className="body-content">
                            <div className="body-content-title">所属商家：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='新增商品'?<div className="content-select-border">
                                            <select className="export-factory msgType " id="couponType">
                                                {
                                                    this.state.businessPassDataAll.map(function (data) {
                                                        return (
                                                            <option value={data.id}>{data.name}</option>
                                                        )
                                                    }.bind(this))
                                                }
                                            </select>
                                        </div>
                                        :
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.companyName}</div>
                                }
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title">商&nbsp;&nbsp;品&nbsp;&nbsp;名：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.name}</div>
                                        :
                                        <div className="content-border">
                                            <input type="text" id="goodsName" className="input-content" placeholder="请填写商品名" maxLength="200"/>
                                        </div>
                                }

                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title ">商&nbsp;&nbsp;品&nbsp;&nbsp;号：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation.indexOf('新增商品') > -1?
                                        <div className="content-border element-content noBorder textInput" >系统自动生成 不需要填写</div>
                                        :
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.uuid}</div>

                                }

                            </div>
                        </div>

                        <div className="body-content" >
                            <div className="body-content-title">商品类型：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTypeValue}</div>
                                        :
                                        <div className="content-select-border">
                                            <select className="export-factory msgType " id="goodsType" >
                                                <option value="1" selected='selected'>免费券</option>
                                                <option value="2" >特价券</option>
                                                <option value="3" >抵用券</option>
                                                <option value="4" >折扣券</option>
                                            </select>
                                        </div>
                                }
                            </div>
                        </div>
                        <div className="body-content" >
                            <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品适用对象：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.cardType=='0'?'所有用户':goodsTrData.cardType=='1'?'白卡用户':'学生证用户'}</div>
                                        :
                                        this.state.addressOrType.teacher?
                                            <div className="content-select-border">
                                                <select className="export-factory msgType " readOnly id="goodsApplyType">
                                                    <option value="0" selected='selected'>所有用户</option>
                                                    {/*<option value="1" >白卡用户</option>*/}
                                                    {/*<option value="2" >学生证用户</option>*/}
                                                </select>
                                            </div>
                                            :
                                            <div className="content-select-border">
                                                <select className="export-factory msgType " id="goodsApplyType" >
                                                    <option value="0" selected='selected'>所有用户</option>
                                                    <option value="1" >白卡用户</option>
                                                    <option value="2" >学生证用户</option>
                                                </select>
                                            </div>
                                }
                            </div>
                        </div>

                        {
                            this.state.navigation=='新增商品'?'':goodsTrData.address?
                                <div>
                                    <div className="body-content" >
                                        <div className="body-content-title">是否展示：</div>
                                        <div className="body-content-text">
                                            <div className="content-border element-content noBorder textInput" >{isShowAddressAll?'是':'否'}</div>
                                        </div>
                                    </div>
                                    {
                                        isShowAddressAll?
                                            <div className="body-content">
                                                <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品使用对象：</div>
                                                <div className="content-border element-content noBorder textInput" >{useObjects}</div>
                                            </div>:''
                                    }
                                    {
                                        isShowAddressAll?
                                            <div className="body-content">
                                                <div className="body-content-title">商品地区：</div>
                                                <div className="body-content-text">
                                                    <div className="content-border element-content noBorder textInput" >{addressAll}</div>
                                                </div>
                                            </div>:''
                                    }

                                </div>
                                :''
                        }
                        {
                            this.state.addressOrType.isShowAddress?this.state.navigation=='新增商品'?
                                <div className="body-content">
                                    <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品使用对象：</div>
                                    <div className="body-content-text">
                                        <div className={this.state.addressOrType.parent?'menu-radio-list checkBox select':'menu-radio-list checkBox '} onClick={this.setAddressOrType.bind(this,'parent')}><span>家长</span></div>
                                        <div className={this.state.addressOrType.teacher?'menu-radio-list checkBox select':'menu-radio-list checkBox'} onClick={this.setAddressOrType.bind(this,'teacher')}><span>老师</span></div>
                                    </div>
                                </div> :'':''

                        }
                        {
                            this.state.navigation=='新增商品'?
                                <div className="body-content" >
                                    <div className="body-content-title">是否展示：</div>
                                    <div className="body-content-text">
                                        <div className="content-select-border">
                                            <select className="export-factory msgType" id="goodsIsShowType" selected={this.state.addressOrType.isShowAddress} onChange={this.changAddressOrType.bind(this)}>
                                                <option value="true" >是</option>
                                                <option value="false" >否</option>
                                            </select>
                                        </div>
                                        <span style={{marginLeft:'10px',lineHeight:'30px'}}>说明：选择是则代表商品可在积分商城中进行展示。</span>
                                    </div>
                                </div>:''
                        }

                        {
                            /**
                             * 商品地区
                             */
                        }
                        {
                            this.state.navigation.indexOf('新增商品') > -1?
                                this.state.addressOrType.isShowAddress?
                                    <Address id="3" type='商品地区' zIndex="1003" goods="true" china={this.state.addressOrType.china} setAddressOrType={this.setAddressOrType}/>:''
                                :''
                        }

                        <div className="body-content">
                            <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品消耗积分：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.consumeCredit}</div>
                                        :
                                        <div className="content-border">
                                            <input type="text" id="goodsConsumeCredit" className="input-content" placeholder="请填写商品消耗积分多少积分" maxLength="11"/>
                                        </div>
                                }
                            </div>
                        </div>
                        <div className="body-content">
                            <div className="body-content-title" style={{width:'120px',backgroundPosition:'92px 4px'}}>商品市场价值：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.price}</div>
                                        :
                                        <div className="content-border">
                                            <input type="text" id="goodsPrice" className="input-content" placeholder="请填写商品市场价值" maxLength="11"/>
                                        </div>
                                }
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title" >券有效期：</div>
                            {
                                this.state.navigation=='商品详情'?
                                    <div className="body-content-text">
                                        <div className="content-border element-content noBorder textInput" >{suixun.getNowFormatDate('yyyy-MM-dd',new Date(goodsTrData.beginTime))}&nbsp;—&nbsp;{suixun.getNowFormatDate('yyyy-MM-dd',new Date(goodsTrData.endTime))}&nbsp;{goodsTrData.validRemark}</div>
                                    </div>
                                    :
                                    <div className="body-content-text">
                                        <div className="content-border content-time" >
                                            <input type="text" className="input-content input-time" id="goodsBeginTime" placeholder="生效时间" maxLength="50" onBlur={this.changeBeginTime.bind(this,'goodsEndTime')}/>
                                        </div>
                                        <span className="content-time-line"/>
                                        <div className="content-border content-time" >
                                            <input type="text" className="input-content input-time" id="goodsEndTime"  placeholder="失效时间" maxLength="50" />
                                        </div>
                                        <div className="content-border" style={{margin:'0 0 0 20px'}}>
                                            <input type="text" id="goodsValidRemark" className="input-content" placeholder="券有效期备注" maxLength="20"/>
                                        </div>
                                    </div>
                            }
                        </div>
                        <div className="body-content">
                            <div className="body-content-title noImg" >使用时间：</div>
                            {
                                this.state.navigation=='商品详情'?
                                    <div className="body-content-text">
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.useTime?goodsTrData.useTime.replace('&',' '):''}</div>
                                    </div>
                                    :
                                    <div className="body-content-text">
                                        <div className="content-border content-time" >
                                            {/*onBlur={this.changeBeginTime.bind(this,'goodsUseEndTime')}*/}
                                            <input type="text" className="input-content input-time" id="goodsUseBeginTime" placeholder="开始时间" maxLength="50" />
                                        </div>
                                        <span className="content-time-line"/>
                                        <div className="content-border content-time" >
                                            <input type="text" className="input-content input-time" id="goodsUseEndTime"  placeholder="结束时间" maxLength="50" />
                                        </div>
                                        <div className="content-border" style={{margin:'0 0 0 20px'}}>
                                            <input type="text" id="goodsUseTimeRemarks" className="input-content" placeholder="使用时间备注" maxLength="20"/>
                                        </div>
                                    </div>
                            }
                        </div>
                        <div className="body-content" style={{display:'none'}}>
                            <div className="body-content-title noImg">是否置顶：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.isTop?'是':'否'}</div>
                                        :
                                        <div className="content-select-border">
                                            <select className="export-factory msgType " selected={goodsTrData.isTop?goodsTrData.isTop:false} id="goodsIsTop">
                                                <option value="false" >否</option>
                                                <option value="true" >是</option>
                                            </select>
                                        </div>
                                }
                            </div>
                        </div>
                        <div className="body-content" >
                            <div className="body-content-title ">商品属性：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder textInput" >
                                            {
                                                goodsTrData.cardProperty==0?'不设置':
                                                    goodsTrData.cardProperty==1?'惠':
                                                        goodsTrData.cardProperty==2?'券':
                                                            goodsTrData.cardProperty==3?'团':
                                                                goodsTrData.cardProperty==4?'亲':'不设置'
                                            }
                                        </div>
                                        :
                                        <div className="content-select-border">
                                            <select className="export-factory msgType " selected={goodsTrData.cardProperty?goodsTrData.cardProperty:1} id="goodsProperty">
                                                {/*<option value="0" >不设置</option>*/}
                                                <option value="1" >惠</option>
                                                <option value="2" >券</option>
                                                {/*<option value="3" >团</option>*/}
                                                {/*<option value="4" >亲</option>*/}
                                            </select>
                                        </div>
                                }
                            </div>
                        </div>
                        <div className="body-content">
                            <div className="body-content-title noImg">套餐内容：</div>
                            <div className="body-content-text" style={{width: '600px'}}>
                                {
                                    this.state.navigation=='商品详情'?
                                        this.state.goodsPackageData.map(function(data, index) {
                                            return (
                                                <div style={{margin:'5px 0 0 0',float: 'left',width:'600px'}}>
                                                    <div className="content-border" style={{width: '160px'}}>
                                                        <input type="text" readOnly className="input-content" value={data.name} />
                                                    </div>
                                                    <div className="content-border"
                                                         style={{width: '160px', marginLeft: '20px'}}>
                                                        <input type="text" readOnly className="input-content" value={data.number} />
                                                    </div>
                                                    <div className="content-border"
                                                         style={{width: '160px', marginLeft: '20px'}}>
                                                        <input type="text" readOnly className="input-content" value={data.price} />
                                                    </div>
                                                </div>
                                            )
                                        }.bind(this))
                                            :
                                        [
                                            this.state.goodsPackageData.map(function(data, index) {
                                                return (
                                                    <div style={{margin:'5px 0 0 0'}}>
                                                        <div className="content-border" style={{width: '160px'}}>
                                                            <input type="text" id={"goodsPackageName"+index} className="input-content" value={data.name} onChange={this.setGoodsPackage.bind(this,index,'name')} placeholder="请填写套餐名称" maxLength="30"/>
                                                        </div>
                                                        <div className="content-border"
                                                             style={{width: '160px', marginLeft: '20px'}}>
                                                            <input type="text" id={"goodsPackageNum"+index} className="input-content" value={data.number} onChange={this.setGoodsPackage.bind(this,index,'number')} placeholder="请填写套餐数量" maxLength="11"/>
                                                        </div>
                                                        <div className="content-border"
                                                             style={{width: '160px', marginLeft: '20px'}}>
                                                            <input type="text" id={"goodsPackagePrice"+index} className="input-content" value={data.price} onChange={this.setGoodsPackage.bind(this,index,'price')} placeholder="请填写套餐价值" maxLength="11"/>
                                                        </div>
                                                        <img onClick={this.deleteGoodsPackage.bind(this,index)} className="deleteImg" src="../img/icon/delete.png"/>
                                                    </div>
                                                )
                                            }.bind(this))
                                                 ,
                                            this.state.goodsPackageData.length == 10?<div style={{height:'5px'}}/>:<div className="header-right-botton" onClick={this.addGoodsPackage.bind(this)} style={{float:'left',margin:'5px 0px 20px 0px'}}>新增套餐</div>
                                        ]

                                }
                            </div>
                        </div>
                        <div className="body-content">
                            <div className="body-content-title">库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存：</div>
                            <div className="body-content-text">
                                {
                                    this.state.navigation.indexOf('新增商品') > -1?
                                        <div className="content-border">
                                            <input type="text" id="goodsNum" className="input-content" placeholder="请填写库存数量" maxLength="11"/>
                                        </div>
                                        :
                                        <div className="content-border element-content noBorder textInput" id="goodsNum" >{goodsTrData.num}</div>
                                }
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title" style={{backgroundPosition: '64px 3px'}}>商品头图：</div>
                            <div className="body-content-text content-file">
                                <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_header" method="post"  style={{display:this.state.navigation=='商品详情'?'none':'block'}}>
                                    <input type="hidden" className="input-fileImg" name="filename"  />
                                    <a href="javascript:;" className="file">
                                        上传图片
                                        <input type="file" name="file" onChange={this.onChangFile.bind(this,'_header')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_header" />
                                    </a>
                                </form>
                                        <div className="upload-show-img" style={{display:this.state.goodsImgData[0].showImg==true?'block':'none'}}>
                                            {
                                                this.state.navigation=='商品详情'?'':<span onClick={this.closeImg.bind(this,'_header')}/>
                                            }
                                            <lable className={this.state.navigation=='新增商品'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_header')} src={this.state.goodsImgData[0].imgUrl} id="showImg_header" onError={this.defaultImg.bind(this)} /></lable>
                                        </div>
                                <span className="inputFile-remarks"  style={{display:this.state.navigation=='商品详情'?'none':'block'}}>说明：用于商品详情页头部图片展示,尺寸为：宽200*高200px,大小限制5M</span>
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title"  style={{width:'100px',backgroundPosition:'80px 4px'}}>图片详情图：</div>
                            <div className="body-content-text content-file">
                                <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_goodsDetails" method="post" style={{display:this.state.navigation=='商品详情'?'none':'block'}}>
                                    <input type="hidden" className="input-fileImg" name="filename"  />
                                    <a href="javascript:void(0);" className="file">
                                        上传图片
                                        <input type="file" name="file" onChange={this.onChangFile.bind(this,'_goodsDetails')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_goodsDetails" />
                                    </a>
                                </form>
                                        <div className="upload-show-img" style={{display:this.state.goodsImgData[1].showImg==true?'block':'none'}}>
                                            {
                                                this.state.navigation=='商品详情'?'':<span onClick={this.closeImg.bind(this,'_goodsDetails')}/>
                                            }
                                            <lable className={this.state.navigation=='新增商品'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_goodsDetails')} src={this.state.goodsImgData[1].imgUrl} id="showImg_goodsDetails" onError={this.defaultImg.bind(this)} /></lable>
                                        </div>
                                <span className="inputFile-remarks"  style={{display:this.state.navigation=='商品详情'?'none':'block'}}>说明：用于商品详情页头部图片展示,尺寸为：宽750*高300px,大小限制5M</span>
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title noImg"  style={{width:'100px',backgroundPosition:'80px 4px'}}>优惠券图片：</div>
                            <div className="body-content-text content-file">
                                <form name="excelInputForm" className="input-from excelInputFrom" id="excelInputFrom_coupon" method="post" style={{display:this.state.navigation=='商品详情'?'none':'block'}}>
                                    <input type="hidden" className="input-fileImg" name="filename"  />
                                    <a href="javascript:void(0);" className="file">
                                        上传图片
                                        <input type="file" name="file" onChange={this.onChangFile.bind(this,'_coupon')}  accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" id="file_coupon" />
                                    </a>
                                </form>
                                        <div className="upload-show-img" style={{display:this.state.goodsImgData[2].showImg==true?'block':'none'}}>
                                            {
                                                this.state.navigation=='商品详情'?'':<span onClick={this.closeImg.bind(this,'_coupon')}/>
                                            }
                                            <lable className={this.state.navigation=='新增商品'?'':'border'}><img onLoad={this.imgLoad.bind(this,'_coupon')} src={this.state.goodsImgData[2].imgUrl} id="showImg_coupon" onError={this.defaultImg.bind(this)} /></lable>
                                        </div>
                                <span className="inputFile-remarks"  style={{display:this.state.navigation=='商品详情'?'none':'block'}}>说明：用于资讯文章下方的领券图片展示,尺寸为：宽500*高130px,大小限制5M</span>
                            </div>
                        </div>

                        <div className="body-content">
                            <div className="body-content-title ">使用规则：</div>
                            <div className="body-content-text">
                                {
                                    // {goodsTrData.contents}
                                    this.state.navigation=='商品详情'?
                                        <div className="content-border element-content noBorder " style={{height:'auto',minHeight:'30px',wordWrap: 'break-word'}} dangerouslySetInnerHTML={{__html: goodsTrData.instructions}} />
                                        :
                                        <div className="content-border content-textarea">
                                            <textarea type="text" id="goodsExplain" className="textarea-content" placeholder="请填写使用规则" maxLength="500"/>
                                        </div>
                                }
                            </div>
                        </div>
                        <div className="body-content">
                            <div className="body-content-title noImg">商品介绍：</div>
                            <div className="body-content-text">
                                <script id="goodsTintroduce" type="text/plain" />
                            </div>
                        </div>

                        {
                            this.state.navigation=='商品详情'?
                                <div className="body-content">
                                    <div className="body-content-title noImg">创建时间：</div>
                                    <div className="body-content-text">
                                        <div className="content-border element-content noBorder textInput" >{goodsTrData.createTime}</div>
                                    </div>
                                </div>
                                : <div className="body-content">
                                    <span className="body-svae" onClick={this.addGoods.bind(this)}>保存</span>
                                </div>
                        }
                        {
                            this.state.navigation=='商品详情'?
                                this.state.menuType==2?
                                    <div className="body-content">
                                        <div className="body-content-title noImg">审核意见：</div>
                                        <div className="body-content-text">
                                            <div className="content-border content-textarea">
                                                <textarea type="text" id="busiOpinion" className="textarea-content" placeholder="请填写审核意见" maxLength="200"/>
                                            </div>
                                        </div>
                                    </div>
                                    :
                                    <div className="body-content">
                                        <span className="body-svae" style={{marginLeft:'0px',marginTop:'-10px'}} onClick={this.setNavigation.bind(this,'商品详情>使用详情')} >使用详情</span>
                                        <div className="body-content-text" style={{paddingLeft:'0',color:'#00b4ed',cursor: 'pointer'}}  onClick={this.setNavigation.bind(this,'商品详情>使用详情')} >
                                            <div className="content-border element-content noBorder textInput"style={{marginLeft:'130px',marginTop:'-6px'}}>领取量：{goodsTrData.totalNum}&nbsp;&nbsp;&nbsp;&nbsp;已使用：{goodsTrData.consumeNum}&nbsp;&nbsp;&nbsp;&nbsp;未使用：{goodsTrData.notConsumeNum}</div>
                                        </div>
                                    </div>
                                :''
                        }
                        {
                            this.state.navigation == '商品详情' ?
                                this.state.menuType == 2?
                                    <div className="body-content">
                                        <span className="body-svae" style={{marginLeft: '120px'}}
                                              onClick={this.goodsExaExamine.bind(this, true, goodsTrData)}>审核通过</span>
                                        <span className="body-svae"
                                              style={{marginLeft: '320px', background: 'rgb(259,89,89)'}}
                                              onClick={this.goodsExaExamine.bind(this, false, goodsTrData)}>审核不通过</span>
                                    </div>
                                    :
                                    <div className="body-content" style={{marginBottom:'20px'}}>
                                        <div className="body-content">
                                            <span className="body-svae" style={{marginLeft:'120px'}} onClick={this.onClickEdit.bind(this,goodsTrData)}>编辑</span>
                                            <span className="body-svae" style={{marginLeft:'320px',background: 'rgb(259,89,89)'}} onClick={this.goodsDelete.bind(this,goodsTrData)}>删除</span>
                                        </div>
                                    </div>
                                :''
                        }
                    </div>




            <footer id="copyright">
                <span><img src="../img/icon/copyright.png"/>{copyright}</span>
            </footer>

            </div>
        );
}
});
/**
 * 获取行政区域组件开始
 * @type {*}
 */
var Address = React.createClass({
    getInitialState:function () {
        return{
            provinceData:[],
            cityData:[],
            countyData:[],
            goods: this.props.goods,//是否启用查询商品地址
        };
    },
    queryAddress:function (num,province,city) {
        if(this.state.goods=='true'){
            var uuid = province==''?'china':province;
            var svar = this;
            suixun.ajax(serverUrl+'/region/getRegions.json?uuid='+uuid,'',"get",function(data){
                if(data.code == 200){
                    if(num == "1"){
                        var provinceData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            provinceData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({provinceData:provinceData});
                    }else if(num == "2"){
                        var cityData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            cityData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({cityData:cityData});
                    }else{
                        var countyData = data.info;
                        for(var i = 0 ;i < data.info.length;i++ ){
                            countyData[i]['value'] = data.info[i].orgName;
                        }
                        svar.setState({countyData:countyData});
                    }
                }
            });
        }else{
            var param="param={";
            param = getJsonDataNotEmpty(param,"type",'"'+num+'"');
            param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
            param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
            param += "}";
            var svar = this;
            suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
                if(data.code == 200){
                    if(num == "1"){
                        var provinceData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            provinceData[i] = {value:data.info[i].province};
                        }
                        svar.setState({provinceData:provinceData});
                    }else if(num == "2"){
                        var cityData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            cityData[i] = {value:data.info[i].city};
                        }
                        svar.setState({cityData:cityData});
                    }else{
                        var countyData = [];
                        for(var i = 0 ;i < data.info.length;i++ ){
                            countyData[i] = {value:data.info[i].town};
                        }
                        svar.setState({countyData:countyData});
                    }
                }
            });
        }
    },
    //查询省份
    queryProvince:function () {
        if($("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='none'&&this.state.provinceData.length>0){
            $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
            $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }else if(this.state.provinceData.length>0){
            $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(1,"","");
        }else{
            this.queryAddress(1,"","");
        }
        $("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
    },
    queryCity:function () {
        if($("#provinceid"+this.props.id+"").next().html()=='选择省份'||$("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            return false;
        }
        if($("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(2,$(".span-provinceid"+this.props.id).attr('data-uuid'),"");
        }else{
            this.queryAddress(2,$(".span-provinceid"+this.props.id).html(),"");
        }
        $("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
        $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
    },
    queryCounty:function () {
        if($("#provinceid"+this.props.id+"").next().html()=='选择省份'||$("#cityid").next().html()=='选择地区'||$("#city"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'
            ||$("#province"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            return false;
        }
        if($("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display')=='block'){
            $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','none');
            return false;
        }
        if(this.state.goods=='true'){
            this.queryAddress(3,$(".span-cityid"+this.props.id).attr('data-uuid'),"");
        }else{
            this.queryAddress(3,"",$(".span-cityid"+this.props.id).html());
        }
        $("#county"+this.props.id+"").find(".body-address-content-selectData"+this.props.id+"").css('display','block');
    },
    render:function () {
        return(
            <div className="body-content">
                <span className="body-content-title" style={this.props.id==2?{width:'120px',backgroundPosition:'92px 4px'}:{}}>商品地址：</span>
                <div className="body-address-contents">
                    <div className={this.props.china?'menu-radio-list checkBox select':'menu-radio-list checkBox'} onClick={this.props.setAddressOrType.bind(this,'china')}><span>全国</span></div>
                        <div className={"body-address-content body-address-content"+this.props.id+""}  id={"province"+this.props.id} style={{display:this.props.china?'none':''}}>
                            <input type="hidden" id={"provinceid"+this.props.id}/>
                            <span className={"body-address-content-default text-sub span-provinceid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryProvince}>选择省份</span>
                            <AddressData type="1" resultData={this.state.provinceData} id={this.props.id} zIndex={this.props.zIndex}/>
                        </div>
                        <div  className={"body-address-content body-address-content"+this.props.id+""} id={"city"+this.props.id}  style={{display:this.props.china?'none':''}}>
                            <input type="hidden" id={"cityid"+this.props.id}/>
                            <span className={"body-address-content-default text-sub span-cityid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryCity}>选择地区</span>
                            <AddressData type="2"  resultData={this.state.cityData} id={this.props.id} zIndex={this.props.zIndex}/>
                        </div>
                        <div className={"body-address-content body-address-content"+this.props.id+""} id={"county"+this.props.id} style={{display:this.props.china?'none':''}}>
                            <input type="hidden" id={"countyid"+this.props.id} value="" data-dataType="Number" data-require="true" data-msg="地区不能为空"/>
                            <span className={"body-address-content-default text-sub span-countyid"+this.props.id+" body-address-content-default"+this.props.id} data-uuid="" title="" onClick={this.queryCounty}>选择县或街道</span>
                            <AddressData type="3"  resultData={this.state.countyData} id={this.props.id} zIndex={this.props.zIndex}/>
                        </div>
                </div>
            </div>
        );
    }
});
/**
 * 省市区组装下拉列表
 * @type {*}
 */
var AddressData = React.createClass({
    componentDidMount:function () {
        $(".body-address-content"+this.props.id+"").hover(function () {
        },function () {
            $(".body-address-content-selectData"+this.props.id+"").css('display','none');
        }.bind(this));
    },
    handleClick:function (data,e) {
        if(this.props.type=="1"){
            $("#city"+this.props.id+"").find(".body-address-content-default").html('选择地区');
            $("#county"+this.props.id+"").find(".body-address-content-default").html('选择县或街道');
            this.setState({cityData:[],countyData:[]});
        }else if(this.props.type=="2"){
            this.setState({countyData:[]});
            $("#county"+this.props.id+"").find(".body-address-content-default").html('选择县或街道');
        }
        $(e.target).parent().prev().html(data.value);
        $($(e.target).parent().prev()).attr("title",data.value);
        $($(e.target).parent().prev()).attr("data-uuid",data.uuid);
        $(e.target).parent().prev().prev().val(data.value);
        $($(e.target).parent()).hide();
    },
    render:function () {
        var svar = this;
        var resultDATA=this.props.resultData.map(function (value,index) {
            return(
                <span onClick={this.handleClick.bind(this,value)} >{value.value}</span>
            );
        }.bind(this));
        return(
            <div className={"body-address-content-selectData body-address-content-selectData"+this.props.id} style={{zIndex: this.props.zIndex}}>
                {resultDATA}
            </div>
        );
    }
});
ReactDOM.render(
    <Main  otherData={otherData} />,
    document.getElementById('tableManage')
);
/**
 * 点击下拉框——下拉框依赖
 */
$(".droup-type").click(function () {
    var dropDown = $('.left-drop-down');
    if(dropDown.is(":hidden")){
        dropDown.slideDown();
    }else{
        dropDown.slideUp();
    }
});
/**
 * 搜索框下拉列表——下拉框依赖
 */
$("*").bind("click",function(e){
    var target = $(e.target);
    if(target.closest(".businessNameList-value").length == 1){
        $("#"+$(target.parent()).attr("data-inputId")+"").val(target.html());
        $(".businessList").hide();
    }else{
        $(".businessList").hide();
    }
});
//时间组件控制
$('#goodsBeginTime').datetimepicker({
    format: "Y-m-d", //格式化日期
    timepicker: false, //显示时间选项
    todayButton: false, //关闭选择今天按钮
    step: 1,//时间间隔
    minDate: suixun.getNowFormatDate('yyyy-MM-dd'), // ,new Date(new Date().getTime()+24*60*60*1000)
});